package datasources.Druid;

import com.alibaba.druid.pool.DruidDataSourceFactory;

import javax.sql.DataSource;
import java.io.InputStream;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.Properties;

public class DruidDemo1 {
    public static void main(String[] args) throws Exception {
        //1. 加载配置文件
        Properties pt = new Properties();
        InputStream is = DruidDemo1.class.getClassLoader().getResourceAsStream("druid.properties");
        pt.load(is);
        //2. 创建连接池对象
        DataSource ds = DruidDataSourceFactory.createDataSource(pt);
        //3. 创建连接对象
        Connection conn = ds.getConnection();
        //4. 创建sql执行对象
        Statement st = conn.createStatement();
        //5. 执行sql语句
        ResultSet rs = st.executeQuery("select * from account");
        rs.next();
        rs.next();
        System.out.println(rs.getInt(2));


    }
}
